<template>
  <div class="table">
    <!-- 顶部搜索区域 -->
    <el-card>
      <el-form v-model="searchDate" ref="searchRef" label-width="100px" class="demo-ruleForm">
        <el-row class="demo-ruleForm-row">
          <el-col :span="6">
            <el-form-item label="项目名称" prop="name">
              <el-input placeholder="请输入招标项目名称" v-model="searchDate.name" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="12">
            <el-form-item label="开标时间" prop="value">
              <el-date-picker v-model="searchDate.value" type="date" placeholder="选择起止日期"></el-date-picker>
              -
              <el-date-picker v-model="searchDate.value1" type="date" placeholder="选择结束日期"></el-date-picker>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="招标编号" prop="infoNumber">
              <el-input placeholder="请输入招标编号" v-model="searchDate.infoNumber" clearable></el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row  class="demo-ruleForm-row">
          <el-col :span="6">
            <el-form-item label="地区" prop="region">
              <el-input placeholder="请输入地区" v-model="searchDate.region" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="6">
            <el-form-item label="采购联系人" prop="procurementContact">
              <el-input placeholder="请输入采购联系人" v-model="searchDate.procurementContact" clearable></el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4" >
            <div class="search_col">
              <el-button type="primary" size="mini" icon="el-icon-search" @click="searchClick">搜索</el-button>
              <el-button type="primary" size="mini" icon="el-icon-refresh" @click="resetForm">重置</el-button>
            </div>
          </el-col>
        </el-row>
      </el-form>
    </el-card>

    <!-- 卡片视图区域 -->
    <el-card class="card">
      <el-row>
        <el-col>
          <el-button icon="el-icon-plus" type="primary" size="mini" @click="addFormDialog">新增项目</el-button>
          <el-button icon="el-icon-files" type="primary" size="mini">导出文件</el-button>
          <!-- <el-button icon="el-icon-folder-opened" type="primary" size="mini"  @click="upDialogVisible = true">导入报名表</el-button>
          <el-button icon="el-icon-folder-opened" type="primary" size="mini" @click="upDialogVisible = true">导入供应商表</el-button>
          <el-button icon="el-icon-folder-opened" type="primary" size="mini" @click="upDialogVisible = true">导入供应商报价表</el-button> -->
        </el-col>
      </el-row>

      <!-- <el-checkbox v-model="checked" @change="handleCheckAllChange(checked)">全选</el-checkbox>
      <el-checkbox v-model="isChecked" :disabled="checkboxList.length === 0" @change="handleIsCheckAllChange(isChecked)">反选</el-checkbox> -->
      <el-table
      :data="data"
      :row-class-name="tableRowClassName"
      style="width: 100%"
      border
      ref="refTable"
      :header-cell-style="{
        'background-color': '#CBD9EC',
        color: '#fff',
        'font-weight': '400',
      }"
      @selection-change="handleSelectionChange"
      @cell-dblclick="dblclickEdit"
      @sort-change="onSortChange">
        <el-table-column
          type="selection"
          width="55">
        </el-table-column>
        <el-table-column width="60" label="序号" type="index"></el-table-column>
        <el-table-column prop="name" label="招标项目名称" width="260"></el-table-column>
        <el-table-column prop="infoNumber" label="招标编号" width="240"> </el-table-column>
        <el-table-column prop="announcement" label="公告发布时间" width="200"> </el-table-column>
        <el-table-column prop="time" label="开标时间" width="200"> </el-table-column>
        <el-table-column prop="region" label="地区" width="200"></el-table-column>
        <el-table-column prop="procurementPeople" label="采购人" width="120"></el-table-column>
        <el-table-column prop="procurementContact" label="采购联系人" width="120"> </el-table-column>
        <el-table-column prop="institutions" label="代理机构" width="120"> </el-table-column>
        <el-table-column prop="responsibility" label="项目负责人" width="120"></el-table-column>
        <el-table-column prop="mobile" label="联系方式" width="150"></el-table-column>
        <el-table-column prop="offerOne" label="第一轮报价" sortable="custom" :sort-orders="['ascending','descending']" width="110"></el-table-column>
        <el-table-column prop="offer_two" label="第二轮报价" sortable="custom" :sort-orders="['ascending','descending']" width="110">
          <template slot-scope="scope">
            <el-input v-if="scope.row.offer_status"
                    ref="kpi"
                    v-model="scope.row.offer_two"
                    style="width: 100%"
                    @blur="changeData(scope.row)">
            </el-input>
            <span v-else>{{scope.row.offer_two}}</span>
          </template>
        </el-table-column>
        <el-table-column prop="procurementWay" label="采购方式"></el-table-column>
        <el-table-column prop="money" label="预算/拟分包金额（万元）" width="130"></el-table-column>
        <el-table-column label="审核状态" width="100"> 
          <template slot-scope="scope">
            <el-tag size="medium" v-if="scope.row.status === 0">未提交</el-tag>
            <el-tag size="medium" v-else-if="scope.row.status === 1">审核中</el-tag>
            <el-tag size="medium" v-else-if="scope.row.status === 2">审核通过</el-tag>
            <el-tag size="medium" v-else>已驳回</el-tag>
          </template>
        </el-table-column>
        <el-table-column label="操作" class="operation" width="100px">
          <template slot-scope="scope">
            <el-row>
              <el-button type="primary" size="mini" @click="checkClick(scope.row.id)">查看</el-button>
            </el-row>
            
            <el-row class="submit_row">
              <el-button type="primary" size="mini" v-if="scope.row.status === 0" 
                @click="reviewClick(scope.row)">选择审核人</el-button>
              <el-button size="mini" @click="open" v-else>已提交</el-button>
            </el-row>

            <el-row class="submit_row">
              <el-button type="danger" icon="el-icon-delete" size="mini" @click="deleteClick(scope.row.id)">删除</el-button>
            </el-row>
          </template>
        </el-table-column>
      </el-table>

      <!-- 分页 -->
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="page.mount"
        :page-sizes="[1, 3, 6, 10]"
        :page-size="page.size"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      >
      </el-pagination>
    </el-card>

    <!-- 新增弹框 -->
    <el-dialog
    title="新增项目基本信息"
    :visible.sync="addDialogVisible"
    @close="addDialogVisibleClosed"
    width="50%">
      <el-form :model="addForm"  ref="addFormRef" label-width="100px" class="demo-ruleForm" :rules="addFormRules">
        <el-form-item label="招标名称" prop="name">
          <el-input v-model="addForm.name"></el-input>
        </el-form-item>
        <el-form-item label="招标编号" prop="infoNumber">
          <el-input v-model="addForm.infoNumber"></el-input>
        </el-form-item>
        <el-form-item label="公告时间" prop="announcement">
          <el-date-picker value-format="yyyy-MM-dd" v-model="addForm.announcement" type="date" placeholder="选择日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="开标时间" prop="time">
          <el-date-picker value-format="yyyy-MM-dd" v-model="addForm.time" type="date" placeholder="选择日期"></el-date-picker>
        </el-form-item>
        <el-form-item label="地区" prop="region">
         <el-cascader :options="cityData" v-model="addForm.region"></el-cascader>
        </el-form-item>
        <el-form-item label="采购人" prop="procurementPeople">
          <el-input v-model="addForm.procurementPeople"></el-input>
        </el-form-item>
        <el-form-item label="采购联系人" prop="procurementContact">
          <el-input v-model="addForm.procurementContact"></el-input>
        </el-form-item>
         <el-form-item label="代理机构" prop="institutions">
          <el-input v-model="addForm.institutions"></el-input>
        </el-form-item>
        <el-form-item label="项目负责人" prop="responsibility">
          <el-input v-model="addForm.responsibility"></el-input>
        </el-form-item>
        <el-form-item label="第一轮报价" prop="offerOne">
          <el-input v-model="addForm.offerOne"></el-input>
        </el-form-item>
        <el-form-item label="联系方式" prop="mobile">
          <el-input v-model="addForm.mobile"></el-input>
        </el-form-item>
        <el-form-item label="采购方式" prop="procurementWay">
          <el-input v-model="addForm.procurementWay"></el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="addDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="addDialog">确 定</el-button>
      </span>
    </el-dialog>

    <!-- 选择审核人弹框 -->
    <el-dialog
      title="选择审核人"
      :visible.sync="reviewDialogVisible"
      @close="reviewDialogVisibleClosed"
      width="30%">
      <el-form :model="reviewForm" :rules="reviewFormRules" ref="reviewFormRef" label-width="100px" class="demo-ruleForm">
        <el-form-item label="选择审核人" prop="review">
          <el-select v-model="reviewForm.review" clearable placeholder="请选择审核人">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value">
            </el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="reviewDialogVisible = false">取 消</el-button>
        <el-button type="primary"  @click="submitClick">确 定</el-button>
      </span>
    </el-dialog>
    
    <!-- 上传弹框 -->
    <el-dialog title="表格数据上传" :visible.sync="upDialogVisible" width="60%" @close="upDialogVisibleClosed">
      <el-form :model="form">
       <el-form-item label="上传文件"  :label-width="formLabelWidth">  
        <el-upload class="upload-demo"
        :on-error="errorClick"
        :on-remove="removeFile"
        :on-success="handleSuccess"
        :before-upload="beforeUploadFile"
        :on-change="fileChange"
         ref="uploadExcel" :auto-upload="false" action="http://192.168.5.197:8040/PM/fileUpload" drag name="fileName" >
          <i class="el-icon-upload"></i>
          <div class="el-upload__text">将文件拖到此处，或<em>点击上传</em></div>
          <div class="el-upload__tip" slot="tip"></div>
        </el-upload>  
       </el-form-item>
     </el-form>
      <span slot="footer" class="dialog-footer">
          <el-button  @click="deleteClicks">取 消</el-button>
          <el-button type="primary" @click="submitUpload">确 定</el-button>
        </span>
    </el-dialog>
  </div>
</template>

<script> 
import cityData from './citydata.js' 
import axios from 'axios'
export default {
  // computeds: {
  //   Pagination
  // },
  data() {
    return {
      formLabelWidth: '80px',
      form: {
        file: []
      },
      fileList: [],
      // 搜索数据
      searchDate: {
        name: '',
        // 开始时间
        value: '',
        // 结束时间
        value1: '',
        infoNumber: '',
        region: '',
        procurementContact: '',
      },
      data: [],
      // 第一个表格
      tableDate: [
        {
          id: 1,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          infoNumber: 'JXRY2020-SR-002-JT(WZ)',
          announcement: '公告',
          time: '2020年6月6日下午16:30时',
          region: '地区',
          procurementPeople: '采购人',
          procurementContact: '采购联系人',
          institutions: '机构1',
          responsibility: '项目负责人',
          mobile: '联系方式',
          offerOne: 0,
          offer_two: 1,
          offer_status: false,
          procurementWay: '采购方式',
          money: 383.46696,
          status: 0,
        },
        {
          id: 2,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          infoNumber: 'JXRY2020-SR-002-JT(WZ)',
          announcement: '公告',
          time: '2020年6月6日下午16:30时',
          region: '地区',
          procurementPeople: '采购人',
          procurementContact: '采购联系人',
          institutions: '机构2',
          responsibility: '项目负责人',
          mobile: '联系方式',
          offerOne: 0,
          offer_two: 2,
          offer_status: false,
          procurementWay: '采购方式',
          money: 383.46696,
          status: 1,
        },
        {
          id: 3,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          infoNumber: 'JXRY2020-SR-002-JT(WZ)',
          announcement: '公告',
          time: '2020年6月6日下午16:30时',
          region: '地区',
          procurementPeople: '采购人',
          procurementContact: '采购联系人',
          institutions: '机构3',
          responsibility: '项目负责人',
          mobile: '联系方式',
          offerOne: 0,
          offer_two: 3,
          procurementWay: '采购方式',
          money: 383.46696,
          status: 2,
        },
        {
          id: 3,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          infoNumber: 'JXRY2020-SR-002-JT(WZ)',
          announcement: '公告',
          time: '2020年6月6日下午16:30时',
          region: '地区',
          procurementPeople: '采购人',
          procurementContact: '采购联系人',
          institutions: '机构3',
          responsibility: '项目负责人',
          mobile: '联系方式',
          offerOne: 0,
          offer_two: 4,
          procurementWay: '采购方式',
          money: 383.46696,
          status: 3,
        },
        {
          id: 5,
          name: '国网江西省电力有限公司上饶供电分公司集体企业2020年第002批物资类招标',
          infoNumber: 'JXRY2020-SR-002-JT(WZ)',
          announcement: '公告',
          time: '2020年6月6日下午16:30时',
          region: '地区',
          procurementPeople: '采购人',
          procurementContact: '采购联系人',
          institutions: '机构1',
          responsibility: '项目负责人',
          mobile: '联系方式',
          offerOne: 0,
          offer_two: 5,
          procurementWay: '采购方式',
          money: 383.46696,
          status: 0,
        },
      ],
      // 控制全选按钮是否选中
      checked: false,
      // 存储选中的数据
      checkboxList: [],
      // 控制反选按钮是否选中
      isChecked: false,

      // 分页数据
      page: {
        // 每页显示几条数据
        size: 6,
        // 当前页码值
        mount: 1,
      },
      listQuery: {
        page: 6, // 当前页码值
        limit: 'limit' // 每页显示几条数据
      },
      // 总数据条数
      total: 6,
      isShow: false,

      // 控制上传弹框的显示隐藏
      upDialogVisible: false,

      // 新增弹框数据区域
      // 控制新增弹框的显示与隐藏
      addDialogVisible: false,
      // 地区数据
      cityData,
      // 新增弹框数据
      addForm: {
        name: '',
        infoNumber: '',
        announcement: '',
        time: '',
        region: '',
        procurementPeople: '',
        procurementContact: '',
        institutions: '',
        responsibility: '',
        offerOne: '',
        mobile: '',
        procurementWay: '',
      },

      // 弹框表单验证规则对象
      addFormRules: {
        name: [
          { required: true, message: '请输入项目名称', trigger: 'blur' }
        ],
        infoNumber: [
          { required: true, message: '请输入招标编号', trigger: 'blur' }
        ],
        announcement: [
          { required: true, message: '请输入公告', trigger: 'blur' }
        ],
        time: [
          { required: true, message: '请输入开标时间', trigger: 'blur' }
        ],
        region: [
          { required: true, message: '请输入地区', trigger: 'blur' }
        ],
        procurementPeople: [
          { required: true, message: '请输入采购人', trigger: 'blur' }
        ],
        procurementContact: [
          { required: true, message: '请输入采购单位联系人', trigger: 'blur' }
        ],
        institutions: [
          { required: true, message: '请输入代理机构', trigger: 'blur' }
        ],
        responsibility: [
          { required: true, message: '请输入项目负责人', trigger: 'blur' }
        ],
        offerOne: [
          { required: true, message: '请输入报价金额', trigger: 'blur' },
          { pattern:/^[0-9]+(.[0-9]{1,4})?$/, message: '报价金额格式不正确', trigger: 'blur' },
        ],
        mobile: [
          { required: true, message: '请输入联系方式', trigger: 'blur' },
          { pattern: /^1[3|4|5|7|8][0-9]{9}$/, message: '联系方式格式不正确', trigger: 'blur' }
        ],
        procurementWay: [
          { required: true, message: '请输入采购方式', trigger: 'blur' }
        ],
      },

      // 审核弹框数据区域
      // 控制审核弹框的显示与隐藏
      reviewDialogVisible: false,
      // 审核人表单数据
      reviewForm: {
        review: ''
      },
      // 审核人表单验证规则对象
      reviewFormRules: {
        review: [
          { required: true, message: '还未选择审核人', trigger: 'blur' }
        ]
      },
      // 选择审核人下拉框数据
      options: [{
        value: '1',
        label: '审核人1'
      }, {
        value: '2',
        label: '审核人2'
      }, {
        value: '3',
        label: '审核人3'
      }],
    }
  },
  methods: {
    // 表格排序事件处理函数
    // @param {object} {column,prop,order} 列数据|排序字段|排序方式
    onSortChange({ prop, order }) {
        this.tableData.sort(this.compare(prop,order));
    },
    // 排序比较
    // @param {string} propertyName 排序的属性名
    // @param {string} sort ascending(升序)/descending(降序)
    // @return {function}
    compare (propertyName, sort) {
        return function (obj1, obj2) {
            var value1 = obj1[propertyName]
            var value2 = obj2[propertyName]
            if (typeof value1 === 'string' && typeof value2 === 'string') {
                const res = value1.localeCompare(value2, 'zh')
                return sort === 'ascending' ? res : -res
            } else {
                if (value1 <= value2) {
                    return sort === 'ascending' ? -1 : 1
                } else if (value1 > value2) {
                    return sort === 'ascending' ? 1 : -1
                }
            }
        }
    },


    //  获取列表数据
    async getList() {
      const {data : res} = await axios({
        method:"POST",
        url:"http://192.168.5.197:8040/project/pageProject",
        headers:{
         'Content-Type': 'application/json;charset=UTF-8',
          type: 'List',
        },
        data:this.page
      }); 
      console.log(res);
      if (res.code !== 1000) {
       return this.$message.error('获取接口失败!!!');
      }
      this.data = res.data.data;
      this.total = res.count;
    },

    // 文件上传成功时的钩子
    handleSuccess(res, file, fileList) {
      // alert(file + '2');
      // 上传成功之后，清空form.file数组
      this.form.file = [];
      this.$notify.success({
        title: '成功',
        message: `文件上传成功`
      });
      // 隐藏 上传弹框
      this.upDialogVisible = false
    },
    // 文件状态改变时的钩子
    fileChange(file, fileList) {
      // fileList中存储了要上传的文件
      // 遍历fileList 
      for(var i = 0; i < fileList.length; i++) {
        // 给 form.file赋值
        this.form.file[i] = file.raw
      }
    },
     // 上传文件之前的钩子, 参数为上传的文件,若返回 false 或者返回 Promise 且被 reject，则停止上传
    beforeUploadFile(file) {
      let extension = file.name.substring(file.name.lastIndexOf('.')+1);
      // 文件大小
      let size = file.size / 1024 / 1024
      // 判断 文件后缀名是否是xlsx
      if(extension !== 'xlsx') {
        this.$notify.warning({
          title: '警告',
          message: `只能上传Excel2017（即后缀是.xlsx）的文件`
        });
        return false;
      }
      if(size > 10) {
        this.$notify.warning({
          title: '警告',
          message: `文件大小不得超过10M`
        });
        return false;
      }
    },
    // 删除文件事件
    removeFile(file, fileList) {
      // 删除文件，数组清空
      this.form.file = []; 
      // // 遍历 lileList
      for(var i = 0; i < fileList.length; i++) {
        // 重新在 form.lile中添加数据
        this.form.file[i] = fileList[i].raw
      }
      
    },
    // 点击取消事件
    deleteClicks() {
      console.log('已经取消上传');
      // 取消请求
      this.$refs.uploadExcel.abort();
      // 隐藏弹框
      this.upDialogVisible = false;
    },
    // 点击上传确认事件
    submitUpload(id) {
      // 手动上传文件，发送请求
      this.$refs.uploadExcel.submit();
      // let formData = new FormData()
      // formData.append('fileName', this.form.file);
      // console.log(this.form.file);
      // console.log(this.formData);
      // axios.post('http://192.168.5.197:8040/PM/fileUpload', 
      //   formData,
      //   { "Content-Type": "multipart/form-data" }
      // )
      // .then(res => {
      //   console.log('res')
      //   console.log(res)
      // })
      // .catch(err => {
      // })
    },
    // 文件上传失败时触发
    errorClick(err, file, fileList) {
      console.log('文件上传失败');
      console.log(err);
      // let myError=err.toString();//转字符串
      // myError=myError.replace("Error: ","") // 去掉前面的" Error: "
      // myError=JSON.parse(myError);//转对象
      // console.log(myError);
    },
    // 监听上传弹框是否隐藏
    upDialogVisibleClosed() {
      this.$refs.uploadExcel.clearFiles();
    },

    // 隔行变色
    tableRowClassName({ row, rowIndex }) {
      if (rowIndex === 1) {
        return 'warning-row'
      } else if (rowIndex === 3) {
        return 'success-row'
      }
      return ''
    },
    // 重置事件
    resetForm() {
      this.searchDate.name = '';
      this.searchDate.value = '';
      this.searchDate.value1 = '';
      this.searchDate.infoNumber = '';
      this.searchDate.region = '';
      this.searchDate.procurementContact = '';
    },
    // 搜索事件
    searchClick() {
      // 总接口
      let url = 'http://192.168.5.197:8040/?page=' + this.page.count + '&size='+this.page.size;
      // 每填一项，都要拼接URL
      if(this.searchDate.name) {
        url += '&name=' + this.searchDate.name;
      }
      // ...
    },

    // 双击编辑
    dblclickEdit(row, column, cell, event) {     
      if(column.property == 'offer_two') {
        console.log(row);
        row.offer_status = true;

        // console.log(row);
        // console.log(column);
        // console.log(cell);
        // console.log(event);
      }
    },
    // input失去焦点事件
    changeData(row) {
      console.log(row);
      row.offer_status = false;
    },

    // 点击新增按钮
    addFormDialog() {
      this.addForm.announcement = new Date();
      this.addForm.time = new Date();
      this.addDialogVisible = true;
    },
    // 点击新增弹框确认事件
    async addDialog() {
      const {data : res} = await axios({
         method:"POST",
        //  url:'http://172.20.10.3:8040/PM/projectDataAdd',
         url:"http://192.168.5.197:8040/project/saveProject",
         headers:{
          'Content-Type': 'application/json;charset=UTF-8',
           type: 'List',
         },
         data:this.addForm
      });
      console.log(res);
      if (res.code !== 1000) {
       return this.$message.error('操作失败!!!');
      }
      // 刷新列表数据
      this.getList();
      // console.log(res);
      // console.log(this.addForm);

      this.$message.success('操作成功');
      this.addDialogVisible = false;
    },
    // 监听新增弹框的显示与隐藏
    addDialogVisibleClosed() {
      this.$refs.addFormRef.resetFields();
    },

    // 每页数据显示条数改变时触发
    handleSizeChange(newSize) {
     this.page.size = newSize;
    // console.log(newSize);
    this.getList();
    },
    // 页码值发生改变时触发
    handleCurrentChange(newPage) {
      // console.log(newPage);
      this.page.mount = newPage;
      this.getList();
    },

    // 点击全选按钮
    handleCheckAllChange(val) {
      // 点击全选，反选不能被选中
      this.isChecked = false;
      // console.log(val);
      // 遍历数组，得到数组中的对象
      for(let item of this.tableDate) {
        // 点击全选，每一个对象的 status都要进行取反
        item.status = true;
      }
      // console.log(this.tableDate);
      // 用三元运算符给 checkboxList 进行赋值
      this.checkboxList = val ? this.tableDate : [];
      // console.log(this.checkboxList);
    },
    // 点击复选框时触发
    handleCheckedCitiesChange(row) {
      // 判断status是否为true
      if(row.status) {
        // 如果为true，则在 checkboxList 末尾增加数据
        this.checkboxList.push(row);
      }else {
        // 如果为false，则删除
        this.checkboxList = this.checkboxList.filter(item => item.status === true)
      }
      // console.log(this.checkboxList);
      this.checkedAll();
    },
    // 全选按钮是否选中
    checkedAll() {
      // 判断 checkboxList的长度 是否等于 tableDate长度
      if(this.checkboxList.length === this.tableDate.length) {
        // 如果相等，说明全选按钮要被选中
        this.checked = true;
      } else {
        // 如果不相等，则全选按钮不被选中
        this.checked = false;
      }
    },
    // 点击反选
    handleIsCheckAllChange(val) {
      // 点击反选，全选则不能被选中
      this.checked = false;
      // 点击了反选，就要清空 checkboxList 数组，才能重新添加数据
      this.checkboxList = [];
      // console.log(val);
      // 遍历得到 tableDate 中的对象
      for(let item of this.tableDate) {
        // 判断 对象的 status 是否为 true
        if(item.status) {
          // 如果为 true，则变为 false
          item.status = false;
        } else {
          // 如果为 false则变为 true
          item.status = true;
          this.checkboxList.push(item);
        }
      }
      console.log(this.checkboxList);
    },

    // 全选
    handleSelectionChange(val) {
      this.checkboxList = val;
      console.log(this.checkboxList);
    },

    // 点击选择审核人
    reviewClick(row) {
      // console.log(row);
      this.reviewDialogVisible = true;
    },
    // 点击选择人弹框确认事件
    submitClick() {
      // 隐藏弹框
      this.reviewDialogVisible = false;
    },
    // 监听选择人弹框的显示与隐藏
    reviewDialogVisibleClosed() {
      this.$refs.reviewFormRef.resetFields();
    },

    // 已提交事件
    open() {
      this.$message('该项目已提交');
    },

    // 点击查看
    checkClick(id) {
      this.$router.push({
        path:`/nested/menu2`,
        query: {
          id:id
        }
      });
    },
    
    // 点击删除事件
    async deleteClick(id) {
      const confirmResult =  this.$confirm('此操作将永久删除该项目, 是否继续?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).catch(err => err);

      console.log(confirmResult);
      // confirmResult 等于 confirm，则表示用户确认删除
      if(confirmResult != 'confirm') {
        return this.$message.info('已经取消删除！');
      }

      // 发送请求

      // 更新数据
    },

    // tab栏选中项改变时触发
    handleClick(tab, event) {
      console.log(tab, event)
    },
  },
  created() {
    // console.log(this.tableDate);
    this.getList();
  },
}
</script>

<style scoped>
.table{
  padding: 20px;
}

.el-input__inner {
  height: 30px !important;
}
.box {
  display: flex;
  justify-items: center;
  align-items: center;
  margin-left: 20px;
  width: 100%;
}
.el-row{
  margin-left: 0px !important;
}
.box p {
  font-size: 14px;
  color: rgb(45, 135, 238);
}
.card{
  width: 100%;
}
.el-row{
  margin-left: 20px;
}
.el-input,
.el-time-picker {
  flex: 1;
}
.el-dialog__body{
  display: flex;
}

.submit_row {
  margin-top: 10px;
}
</style>